home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / SNNSV32.ZIP / SNNSv3.2 / tools / doc / snnsbat.doc < prev   
Encoding:
Text File  |  1994-04-25  |  13.9 KB  |  378 lines

  1. =============================================================================
  2.             Description of the tool SNNSBAT
  3. =============================================================================
  4.  
  5.  
  6.                            Running  SNNS  as  Batch  Job
  7.                            -----------------------------
  8.  
  9.  
  10. Since training a neural network may require several hours of CPU time,
  11. it is advisable to perform this task as a batch job during low usage
  12. times.  SNNS offers the program snnsbat for this purpose. It is
  13. basically an additional interface to the kernel that allows easy
  14. background execution. Its flexible setup allows for a variety of
  15. possible execution modes which can be easily defined in a
  16. configuration file.  All actions and messages are recorded in a log
  17. file for later verification of results.
  18.  
  19.  
  20.  
  21. The Snnsbat Environment
  22. -----------------------
  23.  
  24.  
  25. snnsbat runs very dependable even on instable system configurations
  26. and is secured against data loss due to system crashes, network
  27. failures etc..  On UNIX based systems the program may be terminated
  28. with the command 'kill -15' without loosing the currently computed
  29. network.
  30.  
  31.  
  32. The calling syntax of snnsbat is:
  33.  
  34.             snnsbat [< configuration_file >[< log_file >] ]
  35.  
  36.  
  37. This call starts snnsbat in the foreground. On UNIX systems the
  38. command for background execution is `at', so that the command line
  39.  
  40.             echo 'snnsbat default.cfg log.file' j at 22:00
  41.  
  42. would start the program tonight at 10pm.
  43.  
  44.  
  45. If the optional file names are omitted,snnsbat tries to open the
  46. configuration file `./snnsbat.cfg' and the protocol file
  47. `./snnsbat.log'.
  48.  
  49.  
  50.  
  51. Using Snnsbat
  52. -------------
  53.  
  54. The batch mode execution of SNNS is controlled by the configuration
  55. file.  It contains entries that define the network and parameters
  56. required for program execution.  These entries are tuples (mostly
  57. pairs) of a keyword followed by one or more values.  There is only one
  58. tuple allowed per line, but lines may be separated by an arbitrary
  59. number of comment lines. Comments start with the number sign '#'. The
  60. set of given tuples specify the actions performed by SNNS in one
  61. execution run. An arbitrary number of execution runs can be defined in
  62. one configuration file, by separating the tuple sets with the keyword
  63. 'PerformActions:'. Within a tuple set, the tuples may be listed in any
  64. order. If a tuple is listed several times,values that are already read
  65. are overwritten. The only exception is the key 'Type:',which has to be
  66. listed only once and as the first key. If a key is omitted, the
  67. corresponding value(s) are assigned a default.
  68.  
  69.  
  70.  
  71. Here is a listing of the tuples and their meaning:
  72.  
  73.  
  74.  
  75.   Key                     Value         Meaning                                          
  76.   ----------------------------------------------------------------------------
  77.   InitFunction:           <string>      Name of the initialization function. 
  78.  
  79.   InitParam:              <float>       'NoOfInitParam' parameters for the ini-
  80.                                         tialization function,
  81.                                         separated by blanks.     
  82.  
  83.   LearnParam:             <float>       'NoOfLearnParam'  parameters  for  the
  84.                                         learning function, separated by blanks. 
  85.  
  86.   LearnPatternFile:       <string>      Filename of the learning patterns.   
  87.  
  88.   MaxErrorToStop:         <float>       Network  error  when  learning  can  be
  89.                                         halted.
  90.  
  91.   MaxLearnCycles:         <int>         Maximum number of learning cycles to be
  92.                                         executed.                               
  93.  
  94.   NetworkFile:            <string>      Filename of the net to be trained. 
  95.  
  96.   NoOfInitParam:          <int>         Number of parameters for the initializa-
  97.                                         tion function.
  98.  
  99.   NoOfLearnParam:         <int>         Number of parameters for the learning
  100.                                         function.
  101.  
  102.   NoOfVarDim:          <int> <int>   Number of variable dimensions of the 
  103.                     input and output patterns.
  104.  
  105.   PerformActions:         none          Execution run separator.
  106.  
  107.   ResultFile:             <string>      Filename of the result file. 
  108.  
  109.   ResultIncludeInput:     [ YES j NO ]  Flag for inclusion of input
  110.                     patterns in the result file.       
  111.  
  112.   ResultIncludeOutput:    [ YES j NO ]  Flag for inclusion of output learning 
  113.                     patterns in the result file.                      
  114.  
  115.   ResultMinMaxPattern:    <int> <int>   Number of the first and lastpattern to
  116.                     be used for result file generation.  
  117.  
  118.   Shuffle:                [ YES j NO ]  Flag for pattern shuffling.
  119.  
  120.   SubPatternISize:      <int>        NoOfVarDim[1] int values that specify
  121.                     the shape of the sub patterns of each 
  122.                     input pattern.
  123.  
  124.   SubPatternIStep:      <int>        NoOfVarDim[1] int values that specify
  125.                     the shifting steps for the sub patterns
  126.                     of each input pattern.
  127.  
  128.   SubPatternOSize:      <int>        NoOfVarDim[2] int values that specify
  129.                     the shape of the sub patterns of each 
  130.                     output pattern.
  131.  
  132.   SubPatternOStep:      <int>        NoOfVarDim[2] int values that specify
  133.                     the shifting steps for the sub patterns
  134.                     of each output pattern.
  135.  
  136.   TestPatternFile:        <string>      Filename of the test patterns.
  137.  
  138.   TrainedNetworkFile:     <string>      Filename where the net should be stored
  139.                                         after training / initialization. 
  140.  
  141.   Type:                   <string>      The type of grammar that corresponds to
  142.                                         this file. Valid types are:
  143.                                         'SNNSBATCH 1': performs only one 
  144.                                                    execution run.
  145.                                         'SNNSBATCH 2': performs multiple 
  146.                                execution runs.
  147.  
  148. Please note the mandatory colon after each key and the upper case of
  149. several letters.
  150.  
  151. snnsbat may also be used to perform only parts of a regular network
  152. training run. If the network is not to be initialized,training is not
  153. to be performed, or no result file is to be computed, the
  154. corresponding entries in the configuation file can be omitted.
  155.  
  156. For all keywordsthe string '<OLD>' is also a valid value. If <OLD> is
  157. specified,the value of the previous execution run is kept. For the
  158. keys 'NetworkFile:' and 'LearnPatternFile:' this means, that the
  159. corresponding files are not read in again. The network (patterns)
  160. already in memory are used instead, thereby saving considerabe
  161. execution time.  This allows for a continous logging of network
  162. performance. The user may, for example, load a network and pattern
  163. file, train the network for 100 cycles, create a result file, train
  164. another 100 cycles, create a second result file, and so forth.  Since
  165. the error made by the current network in classifying the patterns is
  166. rep orted in the result file, the series of result files document the
  167. improvement of the network performance.
  168.  
  169. The following table shows the behavior of the program caused by
  170. omitted entries:
  171.  
  172.  
  173.                                        
  174.   missing key                resulting behavior                                                     
  175.   ----------------------------------------------------------------------------
  176.   InitFunction:              The net is not initialized.  
  177.   InitParam:                 Initialization function gets only zero
  178.                  values as parameters.        
  179.   LearnParam:                Learning function gets only zero values as 
  180.                  parameters.              
  181.   LearnPatternFile:          Abort with error message if more than 0 learning 
  182.                  cycles are specified. Initialization can be per- 
  183.                  formed if init function does not require patterns.
  184.   MaxErrorToStop:            Training runs for 'MaxLearnCycles:' cycles.
  185.   MaxLearnCycles:            No training takes place. If training is supposed 
  186.                  to run until MaxErrorToStop, a rather huge number
  187.                  should be supplied here. (skipping this entry 
  188.                  would inhibit training completely).       
  189.   NetworkFile:               Abort with error message.
  190.   NoOfInitParam:             No parameters are assigned to the initialization 
  191.                  function. Error message from SNNS kernel possible.
  192.   NoOfLearnParam:            No parameters are assigned to the learning 
  193.                  function.  Error message from SNNS kernel possible.
  194.   NoOfVarDim:             Network can not handle variable pattern sizes.
  195.   PerformActions:            Only one execution run is performed. Repeated 
  196.                  keywords lead to deletion of older values.
  197.   ResultFile:                No resultfile is generated.
  198.   ResultIncludeInput:        The resultfile does NOT contain input Patterns.
  199.   ResultIncludeOutput:       The resultfile DOES contain learn output Patterns.
  200.   ResultMinMaxPattern:       All patterns are propagated.
  201.   Shuffle:                   Patterns are not shuffled.
  202.   TestPatternFile:           Result file generation uses the learning patterns.
  203.                   If they are not specified either, the program is 
  204.                  aborted with an error message when trying to 
  205.                  generate a result file. 
  206.   TrainedNetworkFile:        Network is not saved after training / init. It is
  207.                  used, however, for result file generation.  
  208.   Type:                      Abort with error message.  
  209.  
  210.  
  211. Here is a typical example of a configuration file:
  212.  
  213.  
  214.  
  215.     #
  216.     Type: SNNSBATCH_2
  217.     #
  218.     # If a key is given twice, the second appearence istaken.
  219.     # Keys that are not required for a special run maybe omitted.
  220.     # If a key is ommited but required, a default valueis assumed.
  221.     # The lines may be separated with comments.
  222.     #
  223.     # Please note the mandatory file type specificationat the begining and
  224.     # the colon follwing the key.
  225.     #
  226.     #######################################################################
  227.     NetworkFile: /home/SNNSv3.0/examples/letters.net
  228.     #
  229.     InitFunction: Randomize_Weights
  230.     NoOfInitParam: 2
  231.     InitParam: -1.0 1.0
  232.     #
  233.     LearnPatternFile: /home/SNNSv3.0/examples/letters.pat
  234.     NoOfLearnParam: 2
  235.     LearnParam: 0.8 0.3
  236.     MaxLearnCycles: 100
  237.     MaxErrorToStop: 1
  238.     Shuffle: YES
  239.     #
  240.     TrainedNetworkFile: trained_letters.net
  241.     ResultFile: letters1.res
  242.     ResultMinMaxPattern: 1 26
  243.     ResultIncludeInput: NO
  244.     ResultIncludeOutput: YES
  245.     #
  246.     #This execution run loads a network and pattern file, initializes the
  247.     #network, trains it for 100 cycles (or stops, if then error is less
  248.     #than 0.01), and finally computes the result file letters1.
  249.     PerformActions:
  250.     #
  251.     NetworkFile: <OLD>
  252.     #
  253.     LearnPatternFile: <OLD>
  254.     NoOfLearnParam: <OLD>
  255.     LearnParam: <OLD>
  256.     MaxLearnCycles: 100
  257.     MaxErrorToStop: 1
  258.     Shuffle: YES
  259.     #
  260.     ResultFile: letters2.res
  261.     ResultMinMaxPattern: <OLD>
  262.     ResultIncludeInput:  <OLD>
  263.     ResultIncludeOutput: <OLD>
  264.     #
  265.     #This execution run continues the training of the already loaded file
  266.     #for another 100 cycles before creating a second result file.
  267.     #
  268.     PerformActions:
  269.     #
  270.     NetworkFile: <OLD>
  271.     #
  272.     LearnPatternFile: <OLD>
  273.     NoOfLearnParam: <OLD>
  274.     LearnParam: 0.2 0.3
  275.     MaxLearnCycles: 100
  276.     MaxErrorToStop: 0.01
  277.     Shuffle: YES
  278.     #
  279.     ResultFile: letters3.res
  280.     ResultMinMaxPattern: <OLD>
  281.     ResultIncludeInput:  <OLD>
  282.     ResultIncludeOutput: <OLD>
  283.     TrainedNetworkFile: trained_letters.net
  284.     #
  285.     #This execution run concludes the training of the already loaded file.
  286.     #After another 100 cycles of training with changed learning
  287.     #parameters the final network is saved to a file and a third result
  288.     #file is created.
  289.     #
  290.  
  291.  
  292.  
  293. The file <log_file> collects the SNNS kernel messages and contains
  294. statistics about running time and speed of the program. An example
  295. protocol file is listed in appendix C of the user manual.
  296.  
  297.  
  298. If the <log_file> command line parameter is omitted, snnsbat opens the
  299. file `snnsbat.log' in the current directory.  To limit the size of this
  300. file, a maximum of 100 learning cycles are logged. This means, that for
  301. 1000 learning cycles a message will be written to the file every 10
  302. cycles.
  303.  
  304.  
  305. If the time required for network training exceeds 30 minutes of CPU
  306. time, the network is saved. The log file then shows the message:
  307.  
  308.  
  309.    #####   Temporary  network  file  'SNNS_Aaaa00457'  created.   #####
  310.  
  311.  
  312. Temporay networks always start with the string `SNNS_'. After 30 more
  313. minutes of CPU time, snnsbat creates a second security copy. Upon normal
  314. termination of the program, these copies are deleted from the current
  315. directory. The log file then shows the message:
  316.  
  317.  
  318.    #####   Temporary  network  file  'SNNS_Aaaa00457'  removed.   #####
  319.  
  320.  
  321. In an emergency (powerdown, kill, alarm, etc.), the current network is
  322. saved by the program. The log file, resp. the mailbox, will later show an
  323. entry like:
  324.  
  325.  
  326.       Signal  15  caught,  SNNS  V3.0  Batchlearning  terminated.
  327.  
  328.  
  329.  
  330.       SNNS  V3.0  Batchlearning  terminated  at  Tue  Mar  23  08:49:04  1993
  331.       System:   SunOS  Node:   matisse  Machine:   sun4m
  332.       Networkfile  './SNNS_BAAa02686'  saved.
  333.       Logfile  'snnsbat.log'  written.
  334.  
  335.  
  336.  
  337. Calling Snnsbat
  338. ---------------
  339.  
  340.  
  341. snnsbat may be called interactively or in batch mode.  It was designed,
  342. however, to be called in batch mode. On Unix machines, the command `at'
  343. should be used, to allow logging the program with the mailbox.
  344. However, `at' can only read from standard input, so a combination of
  345. `echo' and `pipe' has to be used.
  346.  
  347. Three short examples for Unix are given here, to clarify the calls:
  348.  
  349.  
  350.       unix>echo 'snnsbat mybatch.cfg mybatch.log' | at 21:00 Friday
  351.  
  352.  
  353. starts snnsbat next Friday at 9pm with the parameters given in
  354. mybatch.cfg and writes the output to the file mybatch.log in the current
  355. directory.
  356.  
  357.  
  358.       unix>echo 'snnsbat SNNSconfig1.cfg SNNSlog1.log' | at 22
  359.  
  360.  
  361. starts snnsbat today at 10pm
  362.  
  363.  
  364.       unix>echo 'snnsbat' | at now + 2 hours
  365.  
  366.  
  367. starts snnsbat in 2 hours and uses the default files snnsbat.cfg and
  368. snnsbat.log
  369.  
  370. The executable is located in the directory
  371. `.../SNNSv3.1/tools/bin/<machine_type>/'.  The sources of snnsbat can be
  372. found in the directory `.../SNNSv3.1/tools/sources/'.  An example
  373. configuration file was placed in `.../SNNSv3.1/examples'.
  374.  
  375.  
  376. see also SNNS User Manual v3.1  Chapter 10
  377.  
  378.